import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

const router = new Router({
  routes: [
    r("/", "", "base/MainLayout", [
      // 数据罗盘
      r("", "dashboard", "base/Dashboard"),

      // 账户模块
      r("userCenter", "userCenter", "base/userCenter")
    ]),

    r("/login", "login", "base/Login"),
    r("/register", "register", "base/Register"),
    r("*", "404", "base/404")
  ]
});

export default router;

function r(path, name, component, children) {
    return { 
        path: path,
        name: name,
        component: () => import("./views/" + component + ".vue"),
        children: children
    };
}
